package com.job.client.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.ArrayList;
import java.util.List;

//swagger2的配置类，自动生成文档
@Configuration
@EnableSwagger2WebMvc
public class Swagger2Config {

    @Bean
    public Docket clientApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .description("这是321JOB的客户端接口文档")
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("client")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.job.client"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean
    public Docket searchApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        //.title("swagger-bootstrap-ui-demo RESTful APIs")
                        .description("这是321JOB的搜索接口文档")
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("search")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.job.search"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean
    public Docket adminApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        //.title("swagger-bootstrap-ui-demo RESTful APIs")
                        .description("这是321JOB的管理后台接口文档")
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("admin")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.job.admin"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean
    public Docket webSocketApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        //.title("swagger-bootstrap-ui-demo RESTful APIs")
                        .description("这是321JOB的webSocket接口文档")
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("webSocket")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.job.webSocket"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}